﻿using System.Linq;

using vurfu.DataContracts;
using vurfu.Linq;

namespace vurfu.Repositories
{
    public class EventTypeRepository
    {
        public EventType GetEventType(string typeId)
        {
            EventType type;
            using (var connection = DataContextFactory.Create())
            {
                type = (from types in connection.GetTable<EventType>()
                          where types.TypeId == typeId
                          select types).First();
            }
            return type;
        }

        public void SaveEventType(EventType eventType)
        {
            using (var connection = DataContextFactory.Create())
            {
                connection.GetTable<EventType>().InsertOnSubmit(eventType);
                connection.SubmitChanges();
            }
        } 
    }
}